package de.txtippspiel.utils;

import java.text.SimpleDateFormat;

import de.fh.openliga.ws.SportsdataStub.ArrayOfMatchResult;
import de.fh.openliga.ws.SportsdataStub.MatchResult;
import de.fh.openliga.ws.SportsdataStub.Matchdata;

public class ConsolePrinter {
	
	public void printMatchdata(Matchdata m){
		SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyy");
		ArrayOfMatchResult matchResults = m.getMatchResults();
		MatchResult[] results = matchResults.getMatchResult();
		Integer ergTeam1 = null; 
		Integer ergTeam2 = null;
		if(null != results && results.length > 0){
			ergTeam1 = results[0].getPointsTeam1();
			ergTeam2 = results[0].getPointsTeam2();
		}
		StringBuffer sb = new StringBuffer();
		sb.append("Spieltag: " + sdf.format(m.getMatchDateTime().getTime()));
		sb.append(" " + m.getNameTeam1() + " vs. " + m.getNameTeam2());
		sb.append(" = ENDSTAND: " + ergTeam1 + " - " + ergTeam2);
		
		System.out.println(sb.toString());
	}

}
